This plugin acts as a feature-set provider. It does two things: it injects a toolset into the React Editor UI and provides the serialization logic to convert 16x16 pixel arrays into your project's JSON format.
To make this "pop in," the plugin exports a UI component for React and a logic object for the Engine.
// plugins/SpriteEditorPlugin.js
export const SpriteEditorPlugin = {
id: 'sprite-editor',
// 1. Injected UI for React
renderTool(editorProps) {
return <SpriteToolUI palette={PICO8_PALETTE} {...editorProps} />;
},
// 2. Logic for serialization
serialize(pixelData) {
// Converts 16x16 array to compact JSON
return {
type: 'sprite',
size: 16,
data: btoa(pixelData.join('')) // Base64 encoding for size
};
}
};
Your main Editor shell uses an "Extension Registry." On boot, it iterates through loaded plugins and asks if they have a renderTool method. If they do, it mounts them into the Sidebar.
// EditorSidebar.jsx
function EditorSidebar({ plugins }) {
return (
<div>
{plugins.map(p => p.renderTool && p.renderTool())}
</div>
);
}
/plugins directory.SpriteEditorPlugin to the central PluginRegistry.serialize() method to bundle the file.The Core Engine doesn't know "Sprite Editor" exists. It only knows that when it loads a map file, it might contain a sprite data block. The plugin handles the complexity of the 16x16 grid math and color palette, while the Engine just treats the result as another JSON asset to be rendered by PixiJS.